feat: add desktop source path support for app items#1480
feat: add desktop source path support for app items#1480deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds support for tracking the desktop file source path for application items by introducing a new desktopSourcePath property on AppItem, wiring it through the D-Bus-backed AMAppItem constructor, exposing it via a new role in AppItemModel for QML/consumers, and updating build dependencies accordingly. Sequence diagram for propagating DesktopSourcePath into AppItemsequenceDiagram
participant DbusService
participant AMAppItem
participant AppItem
participant AppItemModel
participant QMLView
DbusService->>AMAppItem: construct with appInfo (includes DesktopSourcePath)
AMAppItem->>AMAppItem: desktopSourcePath = appInfo.value(DesktopSourcePath).toString()
AMAppItem->>AppItem: setDesktopSourcePath(desktopSourcePath)
AppItem->>AppItemModel: setData(desktopSourcePath, DesktopSourcePathRole)
QMLView->>AppItemModel: data(index, DesktopSourcePathRole)
AppItemModel-->>QMLView: desktopSourcePath
Class diagram for AppItem desktopSourcePath supportclassDiagram
class AppItem {
+QStringMap execs()
+void setExecs(QStringMap execs)
+QString desktopSourcePath()
+void setDesktopSourcePath(QString desktopSourcePath)
}
class AMAppItem {
+AMAppItem(QDBusObjectPath path, ObjectInterfaceMap source)
}
class AppItemModel {
+int DesktopSourcePathRole
+QHash<int,QByteArray> roleNames()
}
AppItemModel "1" o-- "*" AppItem
AMAppItem --|> AppItem
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In appitem.cpp, there appears to be an extra closing brace after AppItem::setDesktopSourcePath (the function already closes with
}, then there's another}), which will break compilation and should be removed or matched correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In appitem.cpp, there appears to be an extra closing brace after AppItem::setDesktopSourcePath (the function already closes with `}`, then there's another `}`), which will break compilation and should be removed or matched correctly.
## Individual Comments
### Comment 1
<location path="applets/dde-apps/appitem.cpp" line_range="229-231" />
<code_context>
+ return data(AppItemModel::DesktopSourcePathRole).toString();
+}
+
+void AppItem::setDesktopSourcePath(const QString &desktopSourcePath)
+{
+ return setData(desktopSourcePath, AppItemModel::DesktopSourcePathRole);
}
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid returning a value from a `void` function.
This function is declared `void`, but currently does `return setData(...)`, which is invalid C++. To match the signature, remove `return` and just call `setData(desktopSourcePath, AppItemModel::DesktopSourcePathRole);`. In a follow-up, consider updating `setExecs` to use the same pattern for consistency.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Added desktopSourcePath property to AppItem class to store the desktop file source path from D-Bus application info. This enables tracking the original desktop file location for applications, which is useful for debugging and application management. The change includes adding new role in AppItemModel, getter/setter methods in AppItem, and initialization in AMAppItem constructor. Also updated build dependency to require newer dde-application-manager- api version that provides the DesktopSourcePath field. feat: 为应用项添加桌面源路径支持 在AppItem类中添加desktopSourcePath属性,用于存储来自D-Bus应用信息的桌面 文件源路径。 这有助于跟踪应用程序的原始桌面文件位置,对于调试和应用管理非常有用。 更改包括在AppItemModel中添加新角色、在AppItem中添加getter/setter方法以及 在AMAppItem构造函数中进行初始化。 同时更新了构建依赖,要求提供DesktopSourcePath字段的更新版dde- application-manager-api。 PMS: BUG-351621
deepin pr auto review这份代码diff主要包含两部分修改:版权年份更新和新增 1. 版权年份更新-// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
+// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.评价:这是标准的版权年份更新,将版权保护期限延长至2026年,符合规范。 2. 代码质量改进2.1 移除多余的return语句// 修改前
void AppItem::setAppId(const QString &appid)
{
return setData(appid, AppItemModel::DesktopIdRole);
}
// 修改后
void AppItem::setAppId(const QString &appid)
{
setData(appid, AppItemModel::DesktopIdRole);
}评价:
2.2 新增desktopSourcePath功能在appitem.h中:QString desktopSourcePath() const;
void setDesktopSourcePath(const QString &desktopSourcePath);评价:
在appitem.cpp中:QString AppItem::desktopSourcePath() const
{
return data(AppItemModel::DesktopSourcePathRole).toString();
}
void AppItem::setDesktopSourcePath(const QString &desktopSourcePath)
{
setData(desktopSourcePath, AppItemModel::DesktopSourcePathRole);
}评价:
在appitemmodel.h中:enum Roles {
// ...其他角色
DesktopSourcePathRole,
};评价:
在appitemmodel.cpp中:QHash<int, QByteArray> AppItemModel::roleNames() const
{
return {{...}, {AppItemModel::DesktopSourcePathRole, QByteArrayLiteral("desktopSourcePath")}};
}评价:
在amappitem.cpp中:auto desktopSourcePath = appInfo.value(u8"DesktopSourcePath").toString();
AppItem::setDesktopSourcePath(desktopSourcePath);评价:
3. 依赖更新- dde-application-manager-api (>= 1.2.23),
+ dde-application-manager-api (>= 1.2.48),评价:
4. 代码格式问题在appitem.cpp文件末尾: setData(desktopSourcePath, AppItemModel::DesktopSourcePathRole);
}
+}
\ No newline at end of file评价:
5. 综合改进建议
总体来说,这次代码修改质量良好,主要改进了代码一致性(移除多余return语句)并添加了新功能(desktopSourcePath)。建议的改进主要是增强健壮性和文档完善。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Added desktopSourcePath property to AppItem class to store the desktop file source path from D-Bus application info.
This enables tracking the original desktop file location for applications, which is useful for debugging and application management. The change includes adding new role in AppItemModel, getter/setter methods in AppItem, and initialization in AMAppItem constructor. Also updated build dependency to require newer dde-application-manager- api version that provides the DesktopSourcePath field.
feat: 为应用项添加桌面源路径支持
在AppItem类中添加desktopSourcePath属性,用于存储来自D-Bus应用信息的桌面 文件源路径。
这有助于跟踪应用程序的原始桌面文件位置,对于调试和应用管理非常有用。
更改包括在AppItemModel中添加新角色、在AppItem中添加getter/setter方法以及 在AMAppItem构造函数中进行初始化。
同时更新了构建依赖,要求提供DesktopSourcePath字段的更新版dde-
application-manager-api。
PMS: BUG-351621
Summary by Sourcery
Add support for storing and exposing the desktop file source path for application items.
New Features: